import React, { Component } from 'react'
import Header from '../../components/Header/Header'
import {getUser,actions} from "../../store/modules/register"
import { bindActionCreators } from 'redux'
import {connect} from "react-redux"
class Register extends Component {
  
  render() {
    let {
      user,
      r:{ changeUser,doRegister},
      history:{push},
    } = this.props;
    return (
      <div>
        <Header back title="注册"></Header>
        <div>user:{JSON.stringify(user)}</div>
        <div>手机号：<input type="text" value={user.phone} onChange={(e)=>changeUser('phone',e.target.value)} /></div>
        <div>昵称：<input type="text" value={user.nickname} onChange={(e)=>changeUser('nickname',e.target.value)}  /></div>
        <div>密码：<input type="text" value={user.password} onChange={(e)=>changeUser('password',e.target.value)}  /></div>
        <button onClick={() => doRegister(push)}>注册</button>
      </div>
    )
  }
}

const mapStateToProps = (state)=>{
  return{
    user:getUser(state),
  };
};
const mapDispatchToProps = (dispatch)=>{
  return{
    r:bindActionCreators(actions,dispatch),
  };
};
export default connect(mapStateToProps,mapDispatchToProps)(Register);

